package com.bc.service.deal.MtGox;

import java.util.HashMap;

import com.bc.service.BaseResponse;
import com.bc.service.deal.BtcCategory;
import com.bc.utils.CommonUtils;
import com.bc.utils.Constants;
import com.bc.utils.network.GsonUtil;

public class MtGoxResponse extends BaseResponse implements BtcCategory{
	
	Data data;
	String result;
	String item;
	String now;
	
	@Override
	public String toString() {
		return GsonUtil.getGsonInstance().toJson(this);
	}
	
	public static class Item {
		public double value;
		public long value_int;
		public String display;
		public String display_short;
		public String currency;
		
		@Override
		public String toString() {
			return "Item [value=" + value + ", value_int=" + value_int
					+ ", display=" + display + ", display_short="
					+ display_short + ", currency=" + currency + "]";
		}
		
	}
	public static class Data {
		public Item high;
		public Item low;
		public Item avg;
		public Item vwap;
		public Item vol;
		public Item last_local;
		public Item last_orig;
		public Item last_all;
		public Item last;
		public Item buy;
		public Item sell;
		
		@Override
		public String toString() {
			return "Data [high=" + high.toString() + ", low=" + low.toString() + ", avg=" + avg.toString()
					+ ", vwap=" + vwap.toString() + ", vol=" + vol.toString() + ", last_local="
					+ last_local.toString() + ", last_orig=" + last_orig.toString() + ", last_all="
					+ last_all.toString() + ", last=" + last.toString() + ", buy=" + buy.toString() + ", sell="
					+ sell.toString() + "]";
		}
	}
	
	@Override
	public HashMap<String, Object> getBtcNews() {
		HashMap<String, Object> mHashMap = new HashMap<String, Object>();
		if (data != null) {
			Item high = data.high;
			if (high != null) {
				mHashMap.put(Constants.SELL_HIGH_PRICE, CommonUtils.formatNumber("0.00", high.value));
			}
			if (data.low != null) {
				mHashMap.put(Constants.SELL_LOW_PRICE, CommonUtils.formatNumber("0.00", data.low.value));
			}
			if (data.buy != null) {
				mHashMap.put(Constants.BUY_ONE_PRICE, CommonUtils.formatNumber("0.00", data.buy.value));
			}
			if (data.sell != null) {
				mHashMap.put(Constants.SELL_ONE_PRICE, CommonUtils.formatNumber("0.00", data.sell.value));
			}
			if (data.high != null) {
				mHashMap.put(Constants.SELL_HIGH_PRICE, CommonUtils.formatNumber("0.00", data.high.value));
			}
			if (data.last != null) {
				mHashMap.put(Constants.LAST_SALE_PRICE, CommonUtils.formatNumber("0.00", data.last.value));
			}
			if (data.vol != null) {
				mHashMap.put(Constants.SALE_VOLUME, CommonUtils.formatNumber("0.00", data.vol.value));
			}
		}
		return mHashMap;
	}

	@Override
	public String getBtcType() {
		return "MtGoxTicker";
	}
}
